{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <!--<div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name="type"}{else /}asdlkjasd{/present}"
                        href="{:url('index')}">所有用户</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='1'}asdlkjasd{/eq}"
                           href="{:url('member/index',['type'=>'1'])}">付费会员</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='2'}asdlkjasd{/eq}"
                           href="{:url('member/index',['type'=>'2'])}">视频认证(女)</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='3'}asdlkjasd{/eq}"
                           href="{:url('member/index',['type'=>'3'])}">今日注册</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='4'}asdlkjasd{/eq}"
                           href="{:url('member/index',['type'=>'4'])}">男性用户</a>
                        <a class="btn btn-default btn-outline {eq name='type' value='5'}asdlkjasd{/eq}"
                           href="{:url('member/index',['type'=>'5'])}">女性用户</a>
                    </div>-->
                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">
                        <form method="get" action="">
                            <div class="pull-left search">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="type">
                                        <option value="id" {php}if(input(
                                        '?param.type')){if(input('param.type')=='id'){echo "selected";}
                                        }{/php}>会员id</option>
                                        <option value="shangji" {php}if(input(
                                        '?param.type')){if(input('param.type')=='shangji'){echo "selected";}
                                        }{/php}>上级id</option>
                                        <!--<option value="phone" {php}if(input(
                                        '?param.type')){if(input('param.type')=='phone'){echo "selected";}
                                        }{/php}>手机</option>-->
                                    </select>
                                </div>
                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('index')}">返回管理</a>
                                </div>
                                {php}
                                }
                                {/php}
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px"
                                            class="btn btn-default btn-outline" type="submit">搜索
                                    </button>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索会员">
                                </div>


                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th data-align="center">id</th>
                                    <th data-align="center">昵称</th>
                                    <th data-align="center">手机</th>
                                    <th data-align="center">上级id</th>
                                    <th data-align="center">上级昵称</th>
                                    <th data-align="center">上级手机</th>
                                    <th data-align="center">自充值总金额</th>
                                    <th data-align="center">收益提成</th>
                                    <th data-align="center">B级用户数</th>
                                    <th data-align="center">B级充值</th>
                                    <th data-align="center">C级用户数</th>
                                    <th data-align="center">C级充值</th>
                                    <th data-align="center">D级用户数</th>
                                    <th data-align="center">D级充值</th>
                                    <!--<th data-align="center">推广收益</th>-->
                                    <th data-align="center">最后登录</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {php}$hide=array('0'=>'<font color="#f00">禁止</font>','1'=>'<font
                                        color="#1ab394">正常</font>','2'=>'审核','3'=>'<font color="#f00">拒绝</font>');{/php}
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td>{$v.id}</td>
                                    <td>{$v.name}</td>
                                    <td>{$v.phone}</td>
                                    <?php
                                        if ($v['yqr']) {
                                            $s1 = db('user')->where('yqm', $v['yqr'])->find();
                                        } else {
                                            $s1 = ['id' => '', 'name' => '', 'phone' => ''];
                                        }
                                    ?>
                                    <td>{$s1.id}</td>
                                    <td>{$s1.name}</td>
                                    <td>{$s1.phone}</td>
                                    <?php
                                        $topup = db('topup')->where(['type' => ['neq', 2], 'state' => 1, 'fk_userid' => $v['id']])->sum('price');
                                        $topup = number_format($topup, 2);
                                    ?>
                                    <td>{$topup}</td>
                                    <td>{$v.shouyi}</td>
                                    <?php
                                        $b1 = db('user')->where(['yqr' => $v['yqm']])->column('id');
                                    ?>
                                    <td>{:count($b1)}</td>
                                    <?php
                                        if ($b1) {
                                            $topup = db('topup')->where(['type' => ['neq', 2], 'state' => 1, 'fk_userid' => ['in', $b1]])->sum('price');
                                            $topup = number_format($topup, 2);
                                        } else {
                                            $topup = '0.00';
                                        }
                                    ?>
                                    <td>{$topup}</td>
                                    <?php
                                        if ($b1) {
                                            $yqm = db('user')->where(['id' => ['in', $b1]])->column('yqm');
                                            if ($yqm) {
                                                $c1 = db('user')->where(['yqr' => ['in', $yqm]])->column('id');
                                            } else {
                                                $c1 = [];
                                            }
                                        } else {
                                            $c1 = [];
                                        }
                                    ?>
                                    <td>{:count($c1)}</td>
                                    <?php
                                        if ($c1) {
                                            $topup = db('topup')->where(['type' => ['neq', 2], 'state' => 1, 'fk_userid' => ['in', $c1]])->sum('price');
                                            $topup = number_format($topup, 2);
                                        } else {
                                            $topup = '0.00';
                                        }
                                    ?>
                                    <td>{$topup}</td>
                                    <?php
                                        if ($c1) {
                                            $yqm = db('user')->where(['id' => ['in', $c1]])->column('yqm');
                                            if ($yqm) {
                                                $d1 = db('user')->where(['yqr' => ['in', $yqm]])->column('id');
                                            } else {
                                                $d1 = [];
                                            }
                                        } else {
                                            $d1 = [];
                                        }
                                    ?>
                                    <td>{:count($d1)}</td>
                                    <?php
                                        if ($d1) {
                                            $topup = db('topup')->where(['type' => ['neq', 2], 'state' => 1, 'fk_userid' => ['in', $d1]])->sum('price');
                                            $topup = number_format($topup, 2);
                                        } else {
                                            $topup = '0.00';
                                        }
                                    ?>
                                    <td>{$topup}</td>
                                    <!--<td><a onclick="add({$v.id})" style="color:#40BCF7">修改</a></td>-->
                                    <td>{$v.last_login_datetime}</td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}

<script type="text/javascript">
    function del(id) {
        swal_del(id, "{:url('del')}")
    }

    function add(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("add")}?id='+id
            });
        });
    }
</script>
 